package com.jy.rhin.support.polymorphism.convertor;

import cn.org.chiss.rhin._2015.document.management.DocumentStoredQueryResponse;
import com.jy.rhin.sdk.dto.document.DocumentResultDto;
import com.jy.rhin.sdk.dto.document.DocumentSubmissionSetDto;
import com.jy.rhin.sdk.dto.document.query.GetSubmissionSetAndContentsDto;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author dhl
 * @date 2022/6/22
 * @Description
 */
@Service("getSubmissionSetAndContents")
public class DocumentQueryHandler4GetSubmissionSetAndContents extends AbstractDocumentQueryHandler<GetSubmissionSetAndContentsDto, DocumentSubmissionSetDto>{
    @Override
    GetSubmissionSetAndContentsDto convertReq(Map<String, List<String>> dtoValueMap) {
        GetSubmissionSetAndContentsDto dto = new GetSubmissionSetAndContentsDto();
        dto.setId(QueryValueUtils.getStringValue("$SubmissionSetUUID", dtoValueMap));
        dto.setUniqueId(QueryValueUtils.getStringValue("$SubmissionSetUniqueId", dtoValueMap));
        dto.setHomeCommunityId(QueryValueUtils.getStringValue("$HomeCommunityId", dtoValueMap));
        dto.setFormatCodeList(QueryValueUtils.getListValue("$DocumentEntryFormatCode", dtoValueMap));
        dto.setConfidentialityCodeList(QueryValueUtils.getListValue("$DocumentEntryConfidentialityCode", dtoValueMap));
        return dto;
    }

    @Override
    DocumentResultDto<DocumentSubmissionSetDto> query(GetSubmissionSetAndContentsDto dto) {
        return documentSubmissionQueryHandler.getSubmissionSetAndContents(dto);
    }

    @Override
    DocumentStoredQueryResponse convertResp(List<DocumentSubmissionSetDto> resultList, List<String> jsonTextList) {
        return submissionSetConvert(jsonTextList);
    }
}
